package com.antovita.militarymonkey.input;

import com.antovita.militarymonkey.GameMechanics;
import com.antovita.militarymonkey.MyGdxGame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.math.Rectangle;

public class GameInput implements InputProcessor {
	private MyGdxGame gdx;
	private GameMechanics game;
	private Rectangle pauseRect;
	public GameInput(GameMechanics g, MyGdxGame gdx) {
		game = g;
		this.gdx = gdx;
	}
	
	void setGame(GameMechanics g)
	{
		game = g;
	}
	
	@Override
	public boolean keyDown(int keycode) {
		if (keycode == Keys.BACK) {
			gdx.setPauseScreen();
		}
		game.getMonkey().keyDown(keycode);
		return false;
	}

	@Override
	public boolean keyUp(int keycode) {
		game.getMonkey().keyUp(keycode);
		return false;
	}

	@Override
	public boolean keyTyped(char character) {
		return false;
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
	
		pauseRect = new Rectangle(gdx.game.pausePosition.x, gdx.game.pausePosition.y , gdx.game.bananaSprite.getWidth() * 2, gdx.game.bananaSprite.getHeight());
		if (pauseRect.overlaps(new Rectangle(screenX, Gdx.graphics.getHeight() - screenY, 1, 1)))
			gdx.setPauseScreen();
		else
			game.shoot(screenX, screenY);
		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}

}
